﻿<UserControl x:Class="TicketServer.TicketControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:a="clr-namespace:TicketServer.Interfaces.Attributes;assembly=TicketServer.Interfaces"
             xmlns:c="clr-namespace:TicketServer.Common;assembly=TicketServer.Common"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:i="clr-namespace:TicketServer.Interfaces.Enums;assembly=TicketServer.Interfaces"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DesignHeight="450"
             d:DesignWidth="300"
             DataContext="{Binding RelativeSource={RelativeSource Self}}"
             mc:Ignorable="d">
	<UserControl.Resources>
		<a:EnumToFriendlyNameConverter x:Key="enumItemsConverter" />
		<c:Code39ValueConverter x:Key="code39Converter" />
	</UserControl.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="100" />
			<ColumnDefinition />
		</Grid.ColumnDefinitions>

		<Grid.RowDefinitions>
			<RowDefinition Height="24" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="28" />
			<RowDefinition Height="10" />
			<RowDefinition Height="32" />
			<RowDefinition />
		</Grid.RowDefinitions>

		<TextBlock Grid.Row="0"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextId}" />
		<TextBlock Grid.Row="0"
		           Grid.Column="1"
		           Margin="5 0 0 0"
		           HorizontalAlignment="Left"
		           VerticalAlignment="Center"
		           Text="{Binding Ticket.Id,
		                          Mode=OneWay}" />

		<TextBlock Grid.Row="1"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextCode}" />
		<TextBox x:Name="textBoxCode"
		         Grid.Row="1"
		         Grid.Column="1"
		         Margin="3"
		         Text="{Binding Ticket.Code,
		                        UpdateSourceTrigger=Explicit}" />

		<TextBlock Grid.Row="2"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextName}" />
		<TextBox x:Name="textBoxName"
		         Grid.Row="2"
		         Grid.Column="1"
		         Margin="3"
		         Text="{Binding Ticket.Name,
		                        UpdateSourceTrigger=Explicit}" />

		<TextBlock Grid.Row="3"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextStreet}" />
		<TextBox x:Name="textBoxStreet"
		         Grid.Row="3"
		         Grid.Column="1"
		         Margin="3"
		         Text="{Binding Ticket.Street,
		                        UpdateSourceTrigger=Explicit}" />

		<TextBlock Grid.Row="4"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextZip}" />
		<TextBox x:Name="textBoxZip"
		         Grid.Row="4"
		         Grid.Column="1"
		         Margin="3"
		         Text="{Binding Ticket.Zip,
		                        UpdateSourceTrigger=Explicit}" />

		<TextBlock Grid.Row="5"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextCity}" />
		<TextBox x:Name="textBoxCity"
		         Grid.Row="5"
		         Grid.Column="1"
		         Margin="3"
		         Text="{Binding Ticket.City,
		                        UpdateSourceTrigger=Explicit}" />

		<TextBlock Grid.Row="6"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextPhone}" />
		<TextBox x:Name="textBoxPhone"
		         Grid.Row="6"
		         Grid.Column="1"
		         Margin="3"
		         Text="{Binding Ticket.Phone,
		                        UpdateSourceTrigger=Explicit}" />

		<TextBlock Grid.Row="7"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextMail}" />
		<TextBox x:Name="textBoxMail"
		         Grid.Row="7"
		         Grid.Column="1"
		         Margin="3"
		         Text="{Binding Ticket.EMail,
		                        UpdateSourceTrigger=Explicit}" />

		<TextBlock Grid.Row="8"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextRedeemed}" />
		<CheckBox x:Name="checkBoxRedeemed"
		          Grid.Row="8"
		          Grid.Column="1"
		          Margin="5 3 3 3"
		          VerticalAlignment="Center"
		          Checked="checkBoxRedeemed_Checked"
				  Unchecked="checkBoxRedeemed_Checked"
		          IsChecked="{Binding Ticket.IsRedeemed,
		                              Mode=OneWay}" />

		<TextBlock Grid.Row="9"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextRedeemDate}" />
		<DatePickerTextBox x:Name="textBoxRedeemDate"
		                   Grid.Row="9"
		                   Grid.Column="1"
		                   Margin="3"
		                   VerticalContentAlignment="Center"
		                   Text="{Binding Ticket.RedeemDate,
		                                  Mode=OneWay,
		                                  StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" />

		<TextBlock Grid.Row="10"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextOnline}" />
		<CheckBox x:Name="checkBoxOnline"
		          Grid.Row="10"
		          Grid.Column="1"
		          Margin="5 3 3 3"
		          VerticalAlignment="Center"
		          IsChecked="{Binding Ticket.IsOnlineTicket,
		                              Mode=OneWay}" />

		<TextBlock Grid.Row="11"
		           Grid.Column="0"
		           HorizontalAlignment="Right"
		           VerticalAlignment="Center"
		           Text="{LocText TicketServer:Ticket:TextType}" />
		<ComboBox x:Name="comboBoxType"
		          Grid.Row="11"
		          Grid.Column="1"
		          Margin="5 3 3 3"
		          VerticalAlignment="Center"
		          ItemsSource="{Binding Source={c:EnumList {x:Type i:TicketType}}}"
		          SelectedItem="{Binding Ticket.Type,
		                                 Mode=OneWay}">
			<ComboBox.ItemTemplate>
				<DataTemplate>
					<TextBlock Height="Auto"
					           Margin="0"
					           Text="{Binding Path=.,
					                          Mode=OneWay,
					                          Converter={StaticResource enumItemsConverter}}" />
				</DataTemplate>
			</ComboBox.ItemTemplate>
		</ComboBox>

		<Button x:Name="buttonDelete"
		        Grid.Row="13"
		        Grid.Column="0"
		        Margin="5"
		        Click="buttonDelete_Click"
		        Content="{LocText TicketServer::ButtonDelete}" />
		<Button x:Name="buttonSave"
		        Grid.Row="13"
		        Grid.Column="1"
		        Margin="5"
		        Click="buttonSave_Click"
		        Content="{LocText TicketServer::ButtonSave}" />

		<TextBlock Grid.Row="14"
		           Grid.Column="0"
		           Grid.ColumnSpan="2"
		           HorizontalAlignment="Center"
		           VerticalAlignment="Center"
		           FontFamily="C39HrP48DhTt"
		           FontSize="120"
		           SnapsToDevicePixels="True"
		           Text="{Binding Ticket.Code,
		                          Converter={StaticResource ResourceKey=code39Converter}}" />
	</Grid>
</UserControl>
